package com.learning.javaweb_springboot_test.controller;


import com.learning.javaweb_springboot_test.entity.Student;
import com.learning.javaweb_springboot_test.entity.Teacher;
import com.learning.javaweb_springboot_test.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TeacherController {

    @Autowired
    TeacherService teacherService;

    // 插入学生
    @PostMapping("/teachers/add")
    public void addTeacher(@RequestBody Teacher teacher) {
        teacherService.addTeacher(teacher);
    }
    // 根据id删除老师
    @DeleteMapping("/teachers/delete/{id}")
    public void deleteTeacher(@PathVariable Integer id) {
        teacherService.deleteTeacher(id);
    }

    //改
    @PostMapping("/teachers/update")
    public void updateTeacher(@RequestBody Teacher teacher) {
        teacherService.updateTeacher(teacher);
    }

    // 根据ID查询
    @GetMapping("/teachers/{id}")
    public Teacher queryTeacherById(@PathVariable Integer id) {
        return teacherService.queryTeacherById(id);
    }

}
